﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;

namespace ajayumi.develop.win32.Transport.AppUpgrade
{
    /// <summary>
    /// Utility.cs 公共方法类
    /// Author   : 黄乙冬
    /// Date     : 2012-02-23
    /// </summary>
    internal class Utility
    {
        /// <summary>
        /// 备份文件夹名称
        /// </summary>
        internal const string BACKUP_FILE_NAME = "Backup";


        /// <summary>
        /// 获取备份文件路径
        /// </summary>
        internal static string GetBakPath()
        {
            return Path.Combine(ArgumentSerialization.AppDirectory, "bak.zip");
        }

        /// <summary>
        /// 是否有备份
        /// </summary>
        /// <returns></returns>
        internal static bool HasBackup()
        {
            //string dir = Path.Combine(ArgumentSerialization.AppDirectory, BACKUP_FILE_NAME);
            //if (Directory.Exists(dir))
            //{
            //    string[] files = Directory.GetFiles(dir, "*.*");
            //    return files.Length > 0;
            //}
            string path = GetBakPath();
            return File.Exists(path);
        }


        internal static string GetDownloadDir()
        {
            return Path.Combine(ArgumentSerialization.AppDirectory, ArgumentSerialization.AppLatestVersion);
        }


        /// <summary>
        /// 格式化描述字符串，主要是将\\r\\n转换为\r\n
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        internal static string FormatDescription(string desc)
        {
            return desc.Replace("\\r\\n", "\r\n");
        }



    }
}
